Skip to content

Conversation

traeak
Copy link
Contributor

@traeak traeak commented Sep 15, 2025

This adds to the ts api to allows the selected parent strategy to be changed during a transaction using a 'c' friendly API.

APIs added:

Set and get via strategy pointer.

  • void TSHttpTxnNextHopStrategySet(TSHttpTxn txnp, void const *strategy);
  • void const* TSHttpTxnNextHopStrategyGet(TSHttpTxn txnp);

Gets the name of the provided strategy

  • char const* TSHttpNextHopStrategyNameGet(void const *strategy);

The below looks up a strategy by name by using the current transaction to get to the NextHopStrategyFactory.

  • void const* TSHttpTxnNextHopNamedStrategyGet(TSHttpTxn txnp, char const *name);

Support added to:

  • header_rewrite
  • regex_remap
  • lua

Ideally there also should be a way to make the NextHopStrategyFactory pointer directly available to TSRemapNewInstance.

@traeak traeak changed the title API for Strategy rebind during transaction API for Next Hop Strategy rebind during a transaction Sep 15, 2025
@traeak traeak force-pushed the strategy_rebind branch 2 times, most recently from 4009100 to 1d2557d Compare September 22, 2025 22:24
@traeak traeak marked this pull request as ready for review September 23, 2025 15:54
This adds 'c' friendly api calls to get and set strategies,
to get the name of a given strategy and
to get a strategy from the strategy factory by name.

Also includes additions to header_rewrite, regex_remap and lua plugins.
@zwoop
Copy link
Contributor

zwoop commented Sep 25, 2025

Did you email the mailing list with the new API additions ?

@traeak
Copy link
Contributor Author

traeak commented Oct 6, 2025

I think more tests need to be added for corner cases. Also on request am working on setting up a stress test case to ensure that converting the strategy shared_ptr to plain pointers doesn't result in faults.

@bryancall
Copy link
Contributor

@jrushford Hey, do you want to take a look at this PR for us?

@jrushford
Copy link
Contributor

@bryancall Yes, I've been talking with Bryan about it. I'll take a look but, give me a day as I'm currently traveling.

@jrushford
Copy link
Contributor

jrushford commented Oct 16, 2025

I think more tests need to be added for corner cases. Also on request am working on setting up a stress test case to ensure that converting the strategy shared_ptr to plain pointers doesn't result in faults.

+1 on more stress testing. I was worried that changing from shared_ptr to plain pointers might result in memory leaks or crashes when remap.config and strategies.yaml is reloaded. So far though it looks good to me. I'll spin up some VM's and test it.

@traeak
Copy link
Contributor Author

traeak commented Oct 16, 2025

I stress tested using real time traffic replay (with strategies enabled), constantly forcing reloads every few seconds for several hours. I didn't observe any hiccups or issues. (A shame tsan is messy at the moment). Chris' presentation during the summit seemed to agree with my assessment that UrlRewrite which holds the StrategyFactory lives as long as any active transaction are still around, ensuring the strategies live as long as necessary.

Copy link
Contributor

@jrushford jrushford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed it and it looks fine to me and I discussed the stress testing with Brian and am satisfied that this is ok.

@bryancall bryancall added this to the 10.2.0 milestone Oct 20, 2025
@traeak traeak merged commit 9534d95 into apache:master Oct 20, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants